package io.qar.mq.consumer;

import io.qar.mq.entity.OrderCreditsEntity;
import io.qar.mq.entity.OrdersEntity;
import io.qar.mq.service.TransactionLogService;
import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyContext;
import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus;
import org.apache.rocketmq.client.consumer.listener.MessageListenerConcurrently;
import org.apache.rocketmq.common.message.MessageExt;
import org.apache.rocketmq.spring.annotation.MessageModel;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @program: qar-cloud
 * @description:
 * @author: yyyyjinying
 * @create: 2023-10-18 14:47
 **/
@Service
@RocketMQMessageListener(consumerGroup = "test-transation", topic = "test-topic-transation", messageModel = MessageModel.CLUSTERING)
public class RocketMQTransationService implements RocketMQListener<OrdersEntity> {
    @Autowired
    private TransactionLogService transactionLogService;

    @Override
    public void onMessage(OrdersEntity message) {
        transactionLogService.insertOrderCredits(message);
    }
}
